import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'
import { Employee } from './Employee'

@Entity()
export class Department {
    @PrimaryGeneratedColumn()
    id: number

    @Column({
        length: 50,
    })
    name: string

    @OneToMany(() => Employee, (employee) => employee.department, {
        // 只能一方开启cascade, 多方开启会死循环
        // cascade: true
    })
    employees: Employee[]
}
